<template>
	<view class="content">
		<view class="nav-part-bg"></view>
		<view class="body">
			<view class="nav-day">
				<view class="search">
					<u-search placeholder="输入车辆编号或车牌号" :showAction="false" :clearabled="true" shape="square" v-model="keyword"></u-search>
				</view>
			</view>
			<view class="showbody" v-if="cars.length">
				<view class="footer" v-for="(item, index) in cars" :key="index">
					<view class="step-spot" @click="selectCar(item)">
						<view class="foot-head">
							<text>{{ item.plateNumber + '【' + item.vehicleId + '】' }}</text>
						</view>
						<view class="foot-tip">
							<view class="row-tip">
								<view class="cell">
									<text class="cell-title">司机：</text>
									<text class="cell-content">{{ item.driverName }}</text>
									<text class="cell-content">{{ item.driverPhone }}</text>
								</view>
								<view class="cell">
									<view class="cell-row-right">
										<text class="cell-title">线路：</text>
										<text class="cell-content">{{ item.lineName }}</text>
									</view>
								</view>
								<view class="cell">
									<view class="cell-row-right">
										<text class="cell-title">签到时间：</text>
										<text class="cell-content2">{{ item.driverTime }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<empty class="showbody" v-else text="查无数据"></empty>
		</view>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
import selectDay from '@/components/selectDay.vue';
import empty from '@/components/empty.vue';
import globaljs from '@/api/global.js';
import common from '@/utils/common.js';
export default {
	components: { selectDay, empty },
	computed: { ...mapGetters(['operator', 'token']) },
	async onLoad(option) {
		// #ifdef MP
		//未登录转登录页面，已登录转主页面
		if (!this.$store.dispatch('checkIndentity')) return;
		// #endif
		this.getType = option.getType;
		this.initPage();
	},
	data() {
		return {
			getType: 0,
			cars: []
		};
	},
	methods: {
		selectCar(item) {
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2];
			prevPage.$vm.vehicleCode = item.vehicleCode;
			uni.navigateBack({
				delta: 1
			});
		},
		async initPage() {
			//初始加载入站车辆
			let param = {
				stationId: this.operator.stationId,
				token: this.token,
				userId: this.operator.userId,
				getType: this.getType
			};
			let res = await globaljs.getInStationCar(param);
			if (common.httpIsWrong(res)) return;
			this.cars = res.json.data.data;
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	background-color: white;
	.nav-part-bg {
		width: 100%;
		height: 100rpx;
		background-color: #1a90e4;
		position: fixed;
		top: 0;
		z-index: 0;
	}
	.body {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		.nav-day {
			width: 100%;
			height: 100rpx;
			color: white;
			background-color: #1a90e4;
			position: fixed;
			top: var(--window-top, 0);
			z-index: 99;
			.search {
				margin: 0 20rpx;
			}
		}
		.showbody {
			margin-top: 100rpx;
			z-index: 1;
			.footer {
				margin: 20rpx 20rpx;
				border-radius: 10rpx;
				background-color: white;
				box-shadow: 0px 1px 5px #888888;
				.step-spot {
					display: flex;
					flex-direction: column;
					.foot-head {
						height: 80rpx;
						display: flex;
						align-items: center;
						padding-left: 30rpx;
					}
					.foot-tip {
						background-color: #e8f2fe;
						border-radius: 0 0 10rpx 10rpx;
						padding: 0 10rpx;
						.row-tip {
							margin: 10rpx 20rpx;
							display: flex;
							flex-direction: column;
							.tip-m {
								color: #3c9cff;
							}
							.cell {
								padding: 10rpx 0;
								display: flex;
								.cell-title {
									letter-spacing: 10rpx;
									font-size: 28rpx;
								}
								.cell-content {
									letter-spacing: 10rpx;
									font-size: 28rpx;
									color: #1a90e4;
									margin: 0 20rpx;
								}
								.cell-content2 {
									font-size: 28rpx;
									color: #1a90e4;
									margin: 0 20rpx;
								}
								.cell-row-left {
									width: 40%;
								}
								.cell-row-right {
									flex: 1;
								}
								.cell-row {
									width: 50%;
								}
							}
						}
					}
					.collapse {
						width: 100%;
					}
					.step {
						display: flex;
						flex-direction: column;
						.cellbody {
							padding: 10rpx 0;
							display: flex;
							.cellbody-title {
								letter-spacing: 4rpx;
								font-size: 28rpx;
							}
							.cellbody-content {
								font-size: 28rpx;
								letter-spacing: 4rpx;
								color: #1a90e4;
								margin: 0 20rpx;
							}
							.cellbody-content2 {
								font-size: 28rpx;
								letter-spacing: 4rpx;
								color: #1a90e4;
								margin: 0 20rpx;
							}
							.cellbody-row-left {
								width: 50%;
							}
							.cellbody-row-right {
								flex: 1;
							}
							.cellbody-row {
								width: 50%;
							}
						}
					}
				}
			}
		}
	}
}
::v-deep .u-steps.u-steps--column {
	width: 100%;
}
</style>
